<template>
    <view class="xilu">
        <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption"
            :up="upOption">
            <view class="container pt30">
                <navigator :url="'/pages/problem_detail/problem_detail?id='+item.id" open-type="navigate" v-for="(item,index) in articleList">
                    <view class="num">{{(index+1)>10?(index+1):('0'+(index+1))}}</view>
                    <view class="fs30 col10 mb15 m-ellipsis">{{item.name}}</view>
                    <view class="fs24 col89 m-ellipsis-l2">
                        <u-parse :nodes="item.content"></u-parse></view>
                </navigator>
            </view>
        </mescroll-body>
    </view>
</template>

<script>
    // 引入mescroll-mixins.js
    import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
    export default {
        mixins: [MescrollMixin], // 使用mixin
        data() {
            return {
                upOption: {
                    bgColor: "#F7F9FC",
                    textColor:"#aaa"
                },
				articleList:[]
            };
        },
		
		methods:{
			/*上拉加载的回调*/
			upCallback(page) {
				// 此处可以继续请求其他接口
				let pageNum = page.num; // 页码, 默认从1开始
				let pageSize = page.size; // 页长, 默认每页10条
				this.$core.get({
					url: 'xilumarket.article/question',
					loading:false,
					data:{page: pageNum,pageSize:pageSize},
					success: (ret) => {
						let data = ret.data;
						// 接口返回的当前页数据列表 (数组)
						let curPageData = data.data;
						// 接口返回的当前页数据长度 (如列表有26个数据,当前页返回8个,则curPageLen=8)
						let curPageLen = curPageData.length;
						// 接口返回的总页数 (如列表有26个数据,每页10条,共3页; 则totalPage=3)
						let totalPage = data.last_page;
						// 接口返回的总数据量(如列表有26个数据,每页10条,共3页; 则totalSize=26)
				
						//设置列表数据
						if (page.num == 1) this.articleList = []; //如果是第一页需手动置空列表
						this.articleList = this.articleList.concat(curPageData); //追加新数据
				
						// 请求成功,隐藏加载状态
						//方法一(推荐): 后台接口有返回列表的总页数 totalPage
						this.mescroll.endByPage(curPageLen, totalPage);
				
						
						setTimeout(() => {
							this.mescroll.endSuccess(curPageLen)
						}, 20)
					},
					fail: () => {
						//  请求失败,隐藏加载状态
						this.mescroll.endErr()
					}
				})
			},
		}
    }
</script>

<style lang="scss" scoped>
    .xilu {
        .container {
            background-color: #f7f9fc;
        }

        navigator {
            background: #FFFFFF;
            box-shadow: 0rpx 4rpx 20rpx 5rpx rgba(183, 189, 202, 0.05);
            border-radius: 15rpx;
            padding: 30rpx 30rpx 30rpx 108rpx;
            margin: 0 30rpx 20rpx;
            position: relative;
            display: block;

            .num {
                width: 48rpx;
                height: 90rpx;
                background: #FFC100;
                box-shadow: 0rpx 4rpx 20rpx 0rpx rgba(206, 157, 2, 0.3);
                border-radius: 0rpx 0rpx 24rpx 24rpx;
                position: absolute;
                top: 0;
                left: 30rpx;
                text-align: center;
                line-height: 90rpx;
                font-size: 32rpx;
                color: #101010;
            }
        }
    }
</style>
